package com.hunan.hive.controller;

import com.hunan.hive.dao.TestDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/hive")
public class HiveController {
    @Autowired
    @Qualifier("hiveJdbcTemplate")
    private JdbcTemplate hiveJdbcTemplate;

    @Autowired
    public TestDao testDao;


    @RequestMapping("/insert")
    public String insert() {
        hiveJdbcTemplate.execute("insert into user values(1,'Chen')");
        return "Done";
    }

    @RequestMapping("/select")
    public List select() {
        List rows = hiveJdbcTemplate.queryForList("SELECT * FROM test01 limit 10 ");
        return rows;
    }

    @RequestMapping("/select1")
    public List selecthive() {
        List rows = testDao.queryAll();
        return rows;
    }
}
